package com.maodou.core.ui.theme

import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.dp

/**
 * 尺寸系统
 * 提供统一的 dp 尺寸定义，支持自适应布局
 */

// ==================== 基础间距定义 ====================

object Spacing {
    // 超小间距
    val ExtraSmall = 2.dp
    
    // 小间距
    val Small = 4.dp
    
    // 默认间距
    val Default = 8.dp
    
    // 中等间距
    val Medium = 12.dp
    
    // 大间距
    val Large = 16.dp
    
    // 超大间距
    val ExtraLarge = 24.dp
    
    // 巨大间距
    val Huge = 32.dp
    
    // 超巨大间距
    val ExtraHuge = 48.dp
    
    // 最大间距
    val Maximum = 64.dp
}

// ==================== 组件尺寸定义 ====================

object ComponentSizes {
    // 按钮高度
    val ButtonHeightSmall = 32.dp
    val ButtonHeightMedium = 40.dp
    val ButtonHeightLarge = 48.dp
    val ButtonHeightExtraLarge = 56.dp
    
    // 输入框高度
    val TextFieldHeightSmall = 40.dp
    val TextFieldHeightMedium = 48.dp
    val TextFieldHeightLarge = 56.dp
    
    // 图标尺寸
    val IconSizeSmall = 16.dp
    val IconSizeMedium = 24.dp
    val IconSizeLarge = 32.dp
    val IconSizeExtraLarge = 48.dp
    
    // 头像尺寸
    val AvatarSizeSmall = 32.dp
    val AvatarSizeMedium = 48.dp
    val AvatarSizeLarge = 64.dp
    val AvatarSizeExtraLarge = 96.dp
    
    // 卡片最小高度
    val CardMinHeight = 72.dp
    val CardMediumHeight = 120.dp
    val CardLargeHeight = 200.dp
    
    // 列表项高度
    val ListItemHeightSmall = 48.dp
    val ListItemHeightMedium = 56.dp
    val ListItemHeightLarge = 72.dp
    val ListItemHeightExtraLarge = 88.dp
    
    // 工具栏高度
    val ToolbarHeight = 56.dp
    val ToolbarHeightLarge = 64.dp
    
    // 底部导航栏高度
    val BottomNavigationHeight = 56.dp
    val BottomNavigationHeightLarge = 64.dp
    
    // 标签页高度
    val TabHeight = 48.dp
    val TabHeightLarge = 56.dp
    
    // 分割线厚度
    val DividerThickness = 1.dp
    val DividerThicknessBold = 2.dp
}

// ==================== 圆角尺寸定义 ====================

object CornerRadius {
    // 无圆角
    val None = 0.dp
    
    // 小圆角
    val Small = 4.dp
    
    // 默认圆角
    val Default = 8.dp
    
    // 中等圆角
    val Medium = 12.dp
    
    // 大圆角
    val Large = 16.dp
    
    // 超大圆角
    val ExtraLarge = 24.dp
    
    // 圆形
    val Circle = 50.dp
}

// ==================== 边框尺寸定义 ====================

object BorderWidth {
    // 细边框
    val Thin = 1.dp
    
    // 默认边框
    val Default = 2.dp
    
    // 粗边框
    val Thick = 3.dp
    
    // 超粗边框
    val ExtraThick = 4.dp
}

// ==================== 阴影尺寸定义 ====================

object Elevation {
    // 无阴影
    val None = 0.dp
    
    // 小阴影
    val Small = 1.dp
    
    // 默认阴影
    val Default = 2.dp
    
    // 中等阴影
    val Medium = 4.dp
    
    // 大阴影
    val Large = 6.dp
    
    // 超大阴影
    val ExtraLarge = 8.dp
    
    // 最大阴影
    val Maximum = 12.dp
}

// ==================== 内边距定义 ====================

object Padding {
    // 超小内边距
    val ExtraSmall = 4.dp
    
    // 小内边距
    val Small = 8.dp
    
    // 默认内边距
    val Default = 12.dp
    
    // 中等内边距
    val Medium = 16.dp
    
    // 大内边距
    val Large = 20.dp
    
    // 超大内边距
    val ExtraLarge = 24.dp
    
    // 巨大内边距
    val Huge = 32.dp
}

// ==================== 外边距定义 ====================

object Margin {
    // 超小外边距
    val ExtraSmall = 4.dp
    
    // 小外边距
    val Small = 8.dp
    
    // 默认外边距
    val Default = 12.dp
    
    // 中等外边距
    val Medium = 16.dp
    
    // 大外边距
    val Large = 20.dp
    
    // 超大外边距
    val ExtraLarge = 24.dp
    
    // 巨大外边距
    val Huge = 32.dp
}

// ==================== 屏幕断点定义 ====================

object Breakpoints {
    // 小屏幕（手机竖屏）
    val Small = 600.dp
    
    // 中等屏幕（手机横屏、小平板）
    val Medium = 840.dp
    
    // 大屏幕（平板）
    val Large = 1200.dp
    
    // 超大屏幕（桌面）
    val ExtraLarge = 1600.dp
}

// ==================== 自适应尺寸类 ====================

/**
 * 自适应尺寸配置
 * 根据屏幕尺寸提供不同的尺寸值
 */
data class AdaptiveDimensions(
    val small: Dp,
    val medium: Dp,
    val large: Dp,
    val extraLarge: Dp = large
) {
    /**
     * 根据屏幕宽度获取适配的尺寸
     */
    fun getSize(screenWidth: Dp): Dp {
        return when {
            screenWidth < Breakpoints.Small -> small
            screenWidth < Breakpoints.Medium -> medium
            screenWidth < Breakpoints.Large -> large
            else -> extraLarge
        }
    }
    
    companion object
}

// ==================== 预定义自适应尺寸 ====================

object AdaptiveSizes {
    // 自适应间距
    val spacing = AdaptiveDimensions(
        small = Spacing.Default,
        medium = Spacing.Medium,
        large = Spacing.Large,
        extraLarge = Spacing.ExtraLarge
    )
    
    // 自适应内边距
    val padding = AdaptiveDimensions(
        small = Padding.Small,
        medium = Padding.Default,
        large = Padding.Medium,
        extraLarge = Padding.Large
    )
    
    // 自适应按钮高度
    val buttonHeight = AdaptiveDimensions(
        small = ComponentSizes.ButtonHeightMedium,
        medium = ComponentSizes.ButtonHeightLarge,
        large = ComponentSizes.ButtonHeightExtraLarge,
        extraLarge = ComponentSizes.ButtonHeightExtraLarge
    )
    
    // 自适应图标尺寸
    val iconSize = AdaptiveDimensions(
        small = ComponentSizes.IconSizeMedium,
        medium = ComponentSizes.IconSizeLarge,
        large = ComponentSizes.IconSizeExtraLarge,
        extraLarge = ComponentSizes.IconSizeExtraLarge
    )
    
    // 自适应圆角
    val cornerRadius = AdaptiveDimensions(
        small = CornerRadius.Default,
        medium = CornerRadius.Medium,
        large = CornerRadius.Large,
        extraLarge = CornerRadius.ExtraLarge
    )
}

// ==================== 布局相关尺寸 ====================

object LayoutSizes {
    // 最大内容宽度
    val MaxContentWidth = 1200.dp
    
    // 侧边栏宽度
    val SidebarWidth = 280.dp
    val SidebarWidthCompact = 240.dp
    val SidebarWidthExpanded = 320.dp
    
    // 抽屉宽度
    val DrawerWidth = 280.dp
    val DrawerWidthCompact = 240.dp
    
    // 对话框最大宽度
    val DialogMaxWidth = 560.dp
    val DialogMaxWidthCompact = 400.dp
    
    // 卡片最大宽度
    val CardMaxWidth = 400.dp
    
    // 列表最大宽度
    val ListMaxWidth = 600.dp
    
    // 表单最大宽度
    val FormMaxWidth = 480.dp
}

// ==================== 动画相关尺寸 ====================

object AnimationSizes {
    // 滑动距离
    val SwipeDistance = 56.dp
    
    // 拖拽阈值
    val DragThreshold = 16.dp
    
    // 弹性距离
    val ElasticDistance = 24.dp
}